Skip to contentSkip to conversation

Openvpn 2.1.1 bad tcp performance but good ping when -l 1472 (with packet size = MTU)

Openvpn-devel booyakasha 7 participants 16 messages Mar 1, 2010 – Mar 6, 2010 1 message not in the archive

lore
Share & tools
lore

booyakasha

author
#0 lore raw

Hello,
there are so many complains about openvpn performance in proto tcp mode
that it is almost unbelievable that nobody took care of it. I am using two 20/20 MB connections and openvpn
tunnel in tcp mode. without vpn my ping is about 10ms but with vpn it jumps to 520ms. What is most interesting when i use ping -l 1472 which is maximum packet size for MTU 1500 ping is OK and about 13ms. Any other size than 1472 (which means 1500 = 1472 + 28 overhead) causes ping to take values about 500-600ms. And it is not acceptable to use UDP for me because of my company policy. I think that it is very common problem and not yet answered. I am taking wild guess that everything works OK with proper packet size = MTU but when packet is smaller or larger (with fragmentation) it causes lags. Looking forward to your answers.

Best Regards
Ucho

#1 lore raw

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Quoted 5 lines · booyakasha

Hello,
there are so many complains about openvpn performance in proto tcp mode
that it is almost unbelievable that nobody took care of it. I am using two 20/20 MB connections and openvpn
tunnel in tcp mode. without vpn my ping is about 10ms but with vpn it jumps to 520ms. What is most interesting when i use ping -l 1472 which is maximum packet size for MTU 1500 ping is OK and about 13ms. Any other size than 1472 (which means 1500 = 1472 + 28 overhead) causes ping to take values about 500-600ms. And it is not acceptable to use UDP for me because of my company policy. I think that it is very common problem and not yet answered. I am taking wild guess that everything works OK with proper packet size = MTU but when packet is smaller or larger (with fragmentation) it causes lags. Looking forward to your answers.

Could this be related to this?

<http://sites.inka.de/~bigred/devel/tcp-tcp.html>

And in the moment you exceed the MTU size (1500) in your ping requests, you will produce more TCP packets. You might even hit some issues with the Nagle algorithm as well? (have you tried with --socket-flags TCP_NODELAY ?) ... As you have a strict firewall policy, could it be that this causes some issues?

Or it might be that you need some tuning on the --link-mtu, --tun-mtu or
- --tun-mtu-extra? Have you tried running an OpenVPN client with --mtu-test?

Providing more information about your configuration and what you have tried so far would also be helpful, and not just a rather nasty accusation. In many cases, what you complain about here are often connected to configuration issues. Even though, TCP will never ever be as efficient as UDP.

You also don't state if you are using TUN or TAP mode (again, configuration file would help), where TUN is known for having better performance and less overhead than TAP.

So, to sum it up ... you don't provide much information for us to work on ... and to be frankly, this discussion sounds to more belong to the [email protected] list and not the development list, at this point.

kind regards,

David Sommerseth
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (GNU/Linux)
Comment: Using GnuPG with Fedora - http://enigmail.mozdev.org/

iEYEARECAAYFAkuLtkQACgkQDC186MBRfrqaCQCgjHzVkAtIc0cESk5m3ZH0kVoP 29kAn3RB5l08St31BlZSMQb0xdVKVpD4
=uU94
-----END PGP SIGNATURE-----

author
#2 lore raw

Re: [Openvpn-devel] Openvpn 2.1.1 bad tcp performance but good pingwhen -l 1472 (with packet size = MTU)

I spend much time on this problem and it is not simple question of configuration to be
discussed on users forum. I've tried all sort combinations of MTU sizes from extremally small to very big all settings regarding MSS, RWIN, mssfix and so on... I'm not accuseing anyone because of incompetency but many people disvovering this kind of problems was left without a help or told only to use UDP protocol. When i switch to UDP everything works fine byt it is not a solution. I understand problems with tunneling TCP traffic through TCP tunnel but it doesn't answer why it multiplies my ping 50 times. And why packets of exact size of MTU are transmitted flawless? Maybe there is a way to wrap all incomplete packet to match MTU size an push it faster? Of course you can always say that UDP is better but so weak performance of TCP is very hard to bare.

My config client and server is same i'm not using comp-lzo to exclude all external factors. We are using Windows XP / Vista.

client
dev tun
proto tcp-client
remote ...
ca
cert
key
verb 5
route-method exe
route-delay 2
tun-mtu 1500

simple as it is.. and really it is not a problem of MTU or mss.

Best regards
Ucho

Quoted 33 lines

Could this be related to this?

<http://sites.inka.de/~bigred/devel/tcp-tcp.html>

And in the moment you exceed the MTU size (1500) in your ping requests, you will produce more TCP packets. You might even hit some issues with the Nagle algorithm as well? (have you tried with --socket-flags TCP_NODELAY ?) ... As you have a strict firewall policy, could it be that this causes some issues?

Or it might be that you need some tuning on the --link-mtu, --tun-mtu or
- --tun-mtu-extra? Have you tried running an OpenVPN client with --mtu-test?

Providing more information about your configuration and what you have tried so far would also be helpful, and not just a rather nasty accusation. In many cases, what you complain about here are often connected to configuration issues. Even though, TCP will never ever be as efficient as UDP.

You also don't state if you are using TUN or TAP mode (again, configuration file would help), where TUN is known for having better performance and less overhead than TAP.

So, to sum it up ... you don't provide much information for us to work on ... and to be frankly, this discussion sounds to more belong to the [email protected] list and not the development list, at this point.

kind regards,

David Sommerseth

#3 lore raw

Re: [Openvpn-devel] Openvpn 2.1.1 bad tcp performance but good pingwhen -l 1472 (with packet size = MTU)

Quoted 1 line · booyakasha

We are using Windows XP / Vista.

Could you try using the same configuration also on other systems?

Linux, BSD, etc.

I would be interested in knowing if this problem is only seen on Windows.

//Peter

A message that is not in the archive (sent off-list or not yet received): [email protected]...

author
#5 lore raw

Re: [Openvpn-devel] Openvpn 2.1.1 bad tcp performance but good pingwhen -l 1472 (with packet size = MTU)

Dear developers,
because i really believe in open source software I've decided to check all sorts of configurations to check problems with tcp tunneling. I used both Linux and Windows (XP and Vista) to connect them over tcp tunnel in LAN network. I've monitored both sides of connection and I have some interesting results. All 3 machines used fresh installed OS (Linux was Debian 4.1). Same problem with all of them. When you ping them with packet size 1472 (1500 bytes) you have excellent performance on both ends. But using any other size of packet causes dramatic performance lose (about 50 times slower response). What is more interesting no retransmission on any of sides. Just slow response from server and client. But then I’ve tried higher packet sizes just to make sure. And then I found a magic number 2952 (ping –l 2952). It wasn’t only the 1472 ping packet which worked OK. All packets over 2952 are OK !!! I am waiting for your opinions why packets from 1 byte to 2952 bytes (without 1472 byes package) are going extremely slowly and others not. Best regards
Ucho

#6 lore raw

Re: [Openvpn-devel] Openvpn 2.1.1 bad tcp performance but good pingwhen -l 1472 (with packet size = MTU)

Hi,

Quoted 4 lines · booyakasha

magic number 2952 (ping ?l 2952). It wasn?t only the 1472 ping packet which worked OK. All packets over 2952 are OK !!! I am waiting for your opinions why packets from 1 byte to 2952 bytes (without 1472 byes package) are going extremely slowly and others not.

TCP_NODELAY

David has already suggested that you should try setting

"socket-flags TCP_NODELAY"

- did you?

gert

Signature · 4 lines
USENET is *not* the non-clickable part of WWW!
                                                           //www.muc.de/~gert/
Gert Doering - Munich, Germany                             [email protected]...
fax: +49-89-35655025                        [email protected]...
author
#7 lore raw

Re: [Openvpn-devel] Openvpn 2.1.1 bad tcp performance but good pingwhen -l 1472 (with packet size = MTU)

Hi,
yes i tried this setting among many others and it didn't changed nothing at all. But really i would be more than pleased if it was just some switch in config file..

Regards
Ucho

Dnia 4 marca 2010 22:35 Gert Doering <[email protected]...> napisał(a):

Quoted 23 lines

Hi,

Quoted 4 lines · booyakasha

magic number 2952 (ping ?l 2952). It wasn?t only the 1472 ping packet which worked OK. All packets over 2952 are OK !!! I am waiting for your opinions why packets from 1 byte to 2952 bytes (without 1472 byes package) are going extremely slowly and others not.

TCP_NODELAY

David has already suggested that you should try setting

"socket-flags TCP_NODELAY"

- did you?

gert

Signature · 4 lines
USENET is *not* the non-clickable part of WWW!
                                                           //www.muc.de/~gert/
Gert Doering - Munich, Germany                             [email protected]...
fax: +49-89-35655025                        [email protected]...
#8 lore raw

Re: [Openvpn-devel] Openvpn 2.1.1 bad tcp performance but good pingwhen -l 1472 (with packet size = MTU)

In reply to Gert Doering

Hi,

I just tried this, and at least for my data throughput test it didn't seem to help ... buy maybe I have this wrong.

I did this in the client configuration file ... is this right? I checked the OpenVPN web site, and it may be that I need this on the server side instead. Please clarify and I'll try it again (if I need to).

Thanks!

Quoted 1 line · Gert Doering

Hi,

Quoted 33 lines · booyakasha
Quoted 4 lines

magic number 2952 (ping ?l 2952). It wasn?t only the 1472 ping packet which worked OK. All packets over 2952 are OK !!! I am waiting for your opinions why packets from 1 byte to 2952 bytes (without 1472 byes package) are going extremely slowly and others not.

TCP_NODELAY

David has already suggested that you should try setting

"socket-flags TCP_NODELAY"

- did you?

gert
--
USENET is *not* the non-clickable part of WWW!
//http://www.muc.de/~gert/
Gert Doering - Munich, Germany [email protected]...
fax: +49-89-35655025 [email protected]...

------------------------------------------------------------------------------
Download Intel® Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs proactively, and fine-tune applications for parallel performance. See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
_______________________________________________
Openvpn-devel mailing list [email protected]
https://lists.sourceforge.net/lists/listinfo/openvpn-devel

#9 lore raw

Re: [Openvpn-devel] Openvpn 2.1.1 bad tcp performance but good pingwhen -l 1472 (with packet size = MTU)

Hi,

Quoted 4 lines · On Thu, Mar 04, 2010 at 05:21:43PM -0600, [email protected]... wrote:

I did this in the client configuration file ... is this right? I checked the OpenVPN web site, and it may be that I need this on the server side instead. Please clarify and I'll try it again (if I need to).

"socket-flags TCP_NODELAY"

that would need to go into both(!) config files - it changes the way the operating system handles write() calls into a socket, that is, whether the OS waits for "more data" to eventually generate a full sized packet, or whether it will send the data immediately (generating a small packet).

(This is a fundamental problem with TCP - the stacks are optimized for certain patterns, either "bulk data, make full size packets" or "interactive traffic, send single bytes of keystrokes, where a few ms delay don't hurt", but not for VPN-like traffic)

gert

Signature · 4 lines
USENET is *not* the non-clickable part of WWW!
                                                           //www.muc.de/~gert/
Gert Doering - Munich, Germany                             [email protected]...
fax: +49-89-35655025                        [email protected]...
#10 lore raw

Re: [Openvpn-devel] Openvpn 2.1.1 bad tcp performance but good pingwhen -l 1472 (with packet size = MTU)

Hi,

OK, I tried this (on both ends!), but no joy unfortunately ... :-( It almost seemed like overall data throughput was lower, but the throughput results bounce around so much that it's hard to really conclude this or not.

I'm not sure if attachments make it through to this mailing list or not, but let me try to attach a couple pictures showing this with and without OpenVPN (to try to make this easier to see).

Thoughts?

Thanks!

Quoted 1 line · Gert Doering

Hi,

Quoted 27 lines · On Thu, Mar 04, 2010 at 05:21:43PM -0600, [email protected]... wrote:
Quoted 4 lines

I did this in the client configuration file ... is this right? I checked the OpenVPN web site, and it may be that I need this on the server side instead. Please clarify and I'll try it again (if I need to).

"socket-flags TCP_NODELAY"

that would need to go into both(!) config files - it changes the way the operating system handles write() calls into a socket, that is, whether the OS waits for "more data" to eventually generate a full sized packet, or whether it will send the data immediately (generating a small packet).

(This is a fundamental problem with TCP - the stacks are optimized for certain patterns, either "bulk data, make full size packets" or "interactive traffic, send single bytes of keystrokes, where a few ms delay don't hurt", but not for VPN-like traffic)

gert

--
USENET is *not* the non-clickable part of WWW!
//http://www.muc.de/~gert/
Gert Doering - Munich, Germany [email protected]...
fax: +49-89-35655025 [email protected]...

#11 lore raw

Re: [Openvpn-devel] Openvpn 2.1.1 bad tcp performance but good pingwhen -l 1472 (with packet size = MTU)

In reply to Gert Doering
Quoted 15 lines · Gert Doering

Hi,

Quoted 4 lines · On Thu, Mar 04, 2010 at 05:21:43PM -0600, [email protected]... wrote:

I did this in the client configuration file ... is this right? I checked the OpenVPN web site, and it may be that I need this on the server side instead. Please clarify and I'll try it again (if I need to).

"socket-flags TCP_NODELAY"

that would need to go into both(!) config files - it changes the way the operating system handles write() calls into a socket, that is, whether the OS waits for "more data" to eventually generate a full sized packet, or whether it will send the data immediately (generating a small packet).

Quoted 4 lines

(This is a fundamental problem with TCP - the stacks are optimized for certain patterns, either "bulk data, make full size packets" or "interactive traffic, send single bytes of keystrokes, where a few ms delay don't hurt", but not for VPN-like traffic)

Oh WOW... I hadn't even thought of that. That's got to be the A #1 reason right there for avoiding the use of tcp like the plague for things like these.

That means that OpenVPN is (to use the older terminology - I'm old school) not using the PUSH OOB method to push packets out and to get them received immediately at the other end. Looking that the socket_write calls, that would seem to be the MSG_OOB option. I use to remember in days ancient using TCP_URGENT and TCP_PUSH flags for things like that (TCP_URGENT was used by ftp clients to abort interrupted data streams). All I see in socket.h is "MSG_NOSIGNAL". Yeah, that would probably do it. TCP_NODELAY is going to disable the naggle algorithm and disable the send buffering but I don't think it's going to set the TH_PUSH flag in the tcp header so what the received side does with it is up to the received side, isn't it? Yeah, I know, PUSH is an optional feature in tcp implementations but it's been in every one I've worked with and I see the comments about it having it's own problems. But how in the world would anyone expect a user space packet handler to work efficiently over tcp STREAMS without it? You've got to work around tcp's design to treat everything as a continuous stream and to optimize it as a stream and not a series of packets.

If nothing else, I would always expect tcp vpn's the suck royally without at least having TCP_NODELAY. Why isn't that the default.

http://www.unixguide.net/network/socketfaq/2.11.shtml

Quoted 1 line

gert

Mike

Signature · 4 lines
Michael H. Warfield (AI4NB) | (770) 985-6132 |  [email protected]...
   /\/\|=mhw=|\/\/          | (678) 463-0932 |  http://www.wittsend.com/mhw/
   NIC whois: MHW9          | An optimist believes we live in the best of all
 PGP Key: 0x674627FF        | possible worlds.  A pessimist is sure of it!
#12 lore raw

Re: [Openvpn-devel] Openvpn 2.1.1 bad tcp performance but good pingwhen -l 1472 (with packet size = MTU)

Quoted 34 lines · Michael H. Warfield
Quoted 15 lines · Gert Doering

Hi,

Quoted 4 lines · On Thu, Mar 04, 2010 at 05:21:43PM -0600, [email protected]... wrote:

I did this in the client configuration file ... is this right? I checked the OpenVPN web site, and it may be that I need this on the server side instead. Please clarify and I'll try it again (if I need to).

"socket-flags TCP_NODELAY"

that would need to go into both(!) config files - it changes the way the operating system handles write() calls into a socket, that is, whether the OS waits for "more data" to eventually generate a full sized packet, or whether it will send the data immediately (generating a small packet).

Quoted 4 lines

(This is a fundamental problem with TCP - the stacks are optimized for certain patterns, either "bulk data, make full size packets" or "interactive traffic, send single bytes of keystrokes, where a few ms delay don't hurt", but not for VPN-like traffic)

Oh WOW... I hadn't even thought of that. That's got to be the A #1 reason right there for avoiding the use of tcp like the plague for things like these.

That means that OpenVPN is (to use the older terminology - I'm old school) not using the PUSH OOB method to push packets out and to get them received immediately at the other end. Looking that the socket_write calls, that would seem to be the MSG_OOB option. I use to remember in days ancient using TCP_URGENT and TCP_PUSH flags for things like that (TCP_URGENT was used by ftp clients to abort interrupted data streams). All I see in socket.h is "MSG_NOSIGNAL". Yeah, that would probably do it. TCP_NODELAY is going to disable the naggle algorithm and disable the send buffering but I don't think it's going to set the

Quoted 8 lines

TH_PUSH flag in the tcp header so what the received side does with it is up to the received side, isn't it? Yeah, I know, PUSH is an optional feature in tcp implementations but it's been in every one I've worked with and I see the comments about it having it's own problems. But how in the world would anyone expect a user space packet handler to work efficiently over tcp STREAMS without it? You've got to work around tcp's design to treat everything as a continuous stream and to optimize it as a stream and not a series of packets.

Looking at the man page on tcp is appears that MSG_OOB applies the TCP_URGENT semantic to the stream, not the TCP_PUSH. That would also entail a SIGURG signal on each packet on the receiver side. Maybe not such a good thing on every packet after all, even if you set that to SIG_IGNORE. :-P

Quoted 8 lines

If nothing else, I would always expect tcp vpn's the suck royally without at least having TCP_NODELAY. Why isn't that the default.

http://www.unixguide.net/network/socketfaq/2.11.shtml

Quoted 1 line

gert

Mike

Mike

Signature · 4 lines
Michael H. Warfield (AI4NB) | (770) 985-6132 |  [email protected]...
   /\/\|=mhw=|\/\/          | (678) 463-0932 |  http://www.wittsend.com/mhw/
   NIC whois: MHW9          | An optimist believes we live in the best of all
 PGP Key: 0x674627FF        | possible worlds.  A pessimist is sure of it!
#13 lore raw

Re: [Openvpn-devel] Openvpn 2.1.1 bad tcp performance but good pingwhen -l 1472 (with packet size = MTU)

In reply to Michael H. Warfield

Hi,

Quoted 7 lines · Michael H. Warfield

Oh WOW... I hadn't even thought of that. That's got to be the A #1 reason right there for avoiding the use of tcp like the plague for things like these.

That means that OpenVPN is (to use the older terminology - I'm old school) not using the PUSH OOB method to push packets out and to get them received immediately at the other end. Looking that the

I'm not sure what OpenVPN *is* doing internally. I was just assuming that the TCP_NODELAY (nagle) would affect performance for "half-full" packets (as observed).

Since TCP_NODELAY is not having an effect here, it might be worth a look into the sources to see that it's done correctly with TCP_PUSH.

*I* am not going to do that any time soon, though - I'm not using VPN-over-TCP, and digging through the socket code of OpenVPN is fairly far down on my "what to do with OpenVPN in my spare time" list.

gert

Signature · 4 lines
USENET is *not* the non-clickable part of WWW!
                                                           //www.muc.de/~gert/
Gert Doering - Munich, Germany                             [email protected]...
fax: +49-89-35655025                        [email protected]...
#14 lore raw

Re: [Openvpn-devel] Openvpn 2.1.1 bad tcp performance but good pingwhen -l 1472 (with packet size = MTU)

In reply to booyakasha
Quoted 2 lines

because i really believe in open source software I've decided to check all sorts of configurations to check problems with tcp tunneling.

This makes it sound like OpenVPN's performance is lower than some comparable non-Free software.
Have you actually compared OpenVPN's performance to some other TCP-tunnel solution? That would be instructive since it may point to ways to improve the TCP support.

I know in general OpenVPN discourages the use of TCP tunnels and for good reasons, but the support for TCP tunnels is also one of the strengths of OpenVPN, making it usable even with the most uncooperative firewalls.

Stefan

#15 lore raw

Re: [Openvpn-devel] Openvpn 2.1.1 bad tcp performance but good pingwhen -l 1472 (with packet size = MTU)

Hi,

That's a very good suggestion! I just tried this with OpenVPN-ALS (adito), and while the average performance is slightly lower (java vs. compiled code?), the throughput inconsistency is not there, rather it's only the case with OpenVPN!

Attached another throughput plot for you.

Quoted 30 lines · Stefan Monnier

because i really believe in open source software I've decided to check

Quoted 1 line

all sorts of configurations to check problems with tcp tunneling.

This makes it sound like OpenVPN's performance is lower than some comparable non-Free software.
Have you actually compared OpenVPN's performance to some other TCP-tunnel solution? That would be instructive since it may point to ways to improve the TCP support.

I know in general OpenVPN discourages the use of TCP tunnels and for good reasons, but the support for TCP tunnels is also one of the strengths of OpenVPN, making it usable even with the most uncooperative firewalls.

Stefan

------------------------------------------------------------------------------
Download Intel® Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs proactively, and fine-tune applications for parallel performance. See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
_______________________________________________
Openvpn-devel mailing list [email protected]
https://lists.sourceforge.net/lists/listinfo/openvpn-devel

#16 lore raw

Re: [Openvpn-devel] Openvpn 2.1.1 bad tcp performance but good pingwhen -l 1472 (with packet size = MTU)

Quoted 4 lines

That's a very good suggestion! I just tried this with OpenVPN-ALS (adito), and while the average performance is slightly lower (java vs. compiled code?), the throughput inconsistency is not there, rather it's only the case with OpenVPN!

IIUC OpenVPN-ALS is not comparable in that it works in a completely different way which means it can't tunnel just any IP packets. So, it doesn't suffer from "TCP-over-TCP" problems.

Stefan